package miaomaster.service;


import com.miaomaster.UserService;
import jakarta.annotation.Resource;
import org.apache.dubbo.common.stream.StreamObserver;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service
public class OrderService {


    @DubboReference(version = "1.0")
    private UserService userService;


    public String getOrder() {
//        String user = userService.getUser();
        StreamObserver<String> streamObserver = userService.sayHelloStream(new StreamObserver<String>() {
            @Override
            public void onNext(String data) {
                System.out.println(data);
            }

            @Override
            public void onError(Throwable throwable) {

            }

            @Override
            public void onCompleted() {
                System.out.println("客户端发送完毕");
            }
        });

        streamObserver.onNext("1");
        streamObserver.onNext("2");
        streamObserver.onNext("3");
        streamObserver.onCompleted();


        return "success";
    }

}
